public class CountNumbersWithUniqueDigits {

    public int countNumbersWithUniqueDigits(int n) {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int sum = 9;
            for (int j = 0; j < n - i - 1; j++) {
                sum *= (9 - j);
            }
            ans += sum;
        }
        return ans + 1;
    }
}
